package com.ruoyi.ice.domain;

import com.ice.core.annotation.IceNode;
import com.ice.core.context.IceRoam;
import com.ice.core.leaf.roam.BaseLeafRoamFlow;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Date;

@Data
@EqualsAndHashCode(callSuper = true)
@IceNode(name = "日期探针节点", desc = "用于探测roam中日期是否大于等于目标日期")
public class DateFlow extends BaseLeafRoamFlow {

    private String dateStr;

    private String key;


    @Override
    protected boolean doRoamFlow(IceRoam roam) {

        Object value = roam.getMulti(key);

        if (value == null) {
            return false;
        }

        if(StringUtils.isEmpty(dateStr))
            return false;

        Date dateValue = DateUtils.parseDate(value);

        Date date = DateUtils.parseDate(dateStr);

        System.out.println("比较时间:" + dateStr );
        System.out.println("输入时间:" + String.valueOf(value));

        return !(dateValue.before(date));
    }
}
